<?php

class Culture {
    
    /**
     * Format date against culture customer
     * @return String
     */
    public static function FormatDate() {
        switch (Culture::GetLang()){
            case 'fr-fr':
                return 'd-m-Y H:i:s';
                break;
            default:
                return 'Y-m-d H:i:s';
        }
    }
    
    /**
     * Format date from PDO
     * @return string
     */
    public static function FormatDatePDO() {
        switch (Culture::GetLang()){
            case 'fr-fr':
                return 'DD-MM-YYYY HH24:MI';
                break;
            default:
                return 'MM-DD-YYYY HH24:MI';
        }
    }
    
    /**
     * Get Informations culture browser
     */
    public static function GetLang(){
        if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
            preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER["HTTP_ACCEPT_LANGUAGE"], $lang_parse);
//            $rank = $lang_parse[4];
            return $lang_parse[1][1];
        } else {
            return 'en';
        }
    }

}
